<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>银联管理</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/plupload/bootstrap.min.css">
	<script type="text/javascript" src="${ctxStatic}/plupload/plupload.full.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			//实例化一个plupload上传对象
			var uploader = new plupload.Uploader({
				browse_button:"browse", //触发文件选择对话框的按钮，为那个元素id
				url:'${ctx}/product/product/genProduct/upload', //服务器端的上传页面地址
				flash_swf_url: '${ctxStatic}/Moxie.swf', //swf文件，当需要使用swf方式进行上传时需要配置该参数
				silverlight_xap_url: '${ctxStatic}/Moxie.xap', //silverlight文件，当需要使用silverlight方式进行上传时需要配置该参数
				filters : {
				    max_file_size : '100mb'
			    }
			});    

			//在实例对象上调用init()方法进行初始化
			uploader.init();
			//绑定各种事件，并在事件监听函数中做你想做的事
            uploader.bind('BeforeUpload',function(uploader,file){
				//每个事件监听函数都会传入一些很有用的参数，
				console.log("file:" + file);
		    });
		    //绑定各种事件，并在事件监听函数中做你想做的事
            uploader.bind('FilesAdded',function(uploader,files){
				//每个事件监听函数都会传入一些很有用的参数，
				//我们可以利用这些参数提供的信息来做比如更新UI，提示上传进度等操作
                $("#ossfile").empty();
				plupload.each(files, function(file) {
					console.log(uploader);
					uploader.selFile = file;
					if ( file.name != "") {
						$("#configPayManageImage").val(file.name);
					}
					//得到文件夹的名字   保存在div中
					document.getElementById('ossfile').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ')<b></b>' + '<div class="progress" id="ss"><div class="progress-bar" style="width: 0%"></div></div>' + '</div>';			    
				});
		    });
            uploader.bind('UploadProgress',function(uploader,file){
                if (!file || (uploader.selFile.id != file.id)) {
                    return;
                }
				var d = document.getElementById(file.id);
				d.getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
				var prog = d.getElementsByTagName('div')[0];
				var progBar = prog.getElementsByTagName('div')[0]
				progBar.style.width = file.percent + '%';
				progBar.setAttribute('aria-valuenow', file.percent);
		    });
            uploader.bind('UploadComplete',function(uploader,file){
		    });
			document.getElementById('start_upload').onclick = function(){
				uploader.start(); //调用实例对象的start()方法开始上传文件，当然你也可以在其他地方调用该方法
			}
			
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/pay/upop/ecOrgUpop/">银联列表</a></li>
		<li class="active"><a href="${ctx}/pay/upop/ecOrgUpop/form?id=${ecOrgUpop.id}">银联<shiro:hasPermission name="pay:upop:ecOrgUpop:edit">${not empty ecOrgUpop.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="pay:upop:ecOrgUpop:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="ecOrgUpop" action="${ctx}/pay/upop/ecOrgUpop/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="configPayManage.image" id="configPayManageImage"/>
		<sys:message content="${message}"/>	
		<div class="control-group">
			<label class="control-label">域 银行编码：</label>
			<div class="controls">
				<form:input path="bankId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">域 银行名称：</label>
			<div class="controls">
				<form:input path="bankName" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">域 商户编号：</label>
			<div class="controls">
				<form:input path="merchantId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">域 银行调用业务系统的后台结果通知地址：</label>
			<div class="controls">
				<form:input path="resultNotityUrlBg" htmlEscape="false" maxlength="512" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">域 银行调用业务系统的前台结果通知地址：</label>
			<div class="controls">
				<form:input path="resultNotityUrlFg" htmlEscape="false" maxlength="512" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">主图：</label>
			<div class="controls">
				<p id="ossfile"></p>
				<input type="button" value="选择文件"  id="browse" accept=".BMP,.JPG,.JPEG,PNG,GIF" class="color ci_width_90 zl_loading" />
				<input type="button" value="开始上传" id="start_upload" class="color ci_width_90 zl_loading" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="pay:upop:ecOrgUpop:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>